﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using BOHVote.BLL;
using System.IO;
using BOHVote.Common;
using System.Net;
using BOHVote.Entity;

namespace BOH.Information
{
    public partial class NewApply : System.Web.UI.Page
    {
        public static DataSet dstJobRank = null;

        private string ImgApplyPhotoPath = string.Empty;
        private string PaperImagePath1 = string.Empty;
        private string PaperImagePath2 = string.Empty;
        private string PaperImagePath3 = string.Empty;
        private string PaperImagePath4 = string.Empty;
        private string UserID = string.Empty;

        protected string PageType = string.Empty;
        protected string ID = string.Empty;
        protected BHUser user = null;
 
        protected void Page_Load(object sender, EventArgs e)
        {
            PageType = Request.QueryString["type"];
            ID = Request.QueryString["ID"];
            //txtGraduationTime.Attributes.Add("readonly", "true");
            //txtGetJobRankTime.Attributes.Add("readonly", "true");
            //txtConversionDate.Attributes.Add("readonly", "true");
            //txtLastApplyTime.Attributes.Add("readonly", "true");
            //txtSpecialityEndTime.Attributes.Add("readonly", "true");
            //txtAwardsDateTime.Attributes.Add("readonly", "true");
            if (!IsPostBack)
            {
                BindTogether();
                BindCurrentJobRank();
                //drpCurrentJobRank_SelectedIndexChanged(null, null);
                BindApplyJobRank("");
                LanguageBInd();
                BindPeriod();
                hidApplyPeriod.Value = (string)Session["ApplyPeriod"];
                SubjectBind(null);
                if(Session["User"]!=null)
                {
                    user = (BHUser)Session["User"];
                    if (user.RightType == "U")
                         UnitDropBind(user.UnitID.Trim(), user.GovernID);
                    else if (user.RightType == "G")
                        UnitGovernBind(user.GovernID);
                    else if (user.RightType == "C" || user.RightType == "A")
                        UnitGovernBind("");
                     UserID = user.UserID;
                     if (user.RightType == "P")
                     {
                         UnitDropBind(user.UnitID.Trim(), user.GovernID);
                         string ApplyID = string.Empty;
                         string ApplyPeriod = PeriodClass.getAperiod().Tables[0].Rows[0]["ApplyPeriodID"].ToString();
                         
                         DataSet dstApplyID = ApplyClass.getApplyDataSetByIDCardAndPeriod(user.UserCode, ApplyPeriod);
                         if (dstApplyID.Tables.Count > 0 && dstApplyID.Tables[0].Rows.Count > 0)
                             ApplyID = ApplyClass.getApplyDataSetByIDCardAndPeriod(user.UserCode, ApplyPeriod).Tables[0].Rows[0]["ApplyID"].ToString();
                         if (!string.IsNullOrEmpty(ApplyID))
                         {
                             PageType = "edit";
                             ID = ApplyID;
                             txtIDCard.Enabled = false;
                         }
                         else
                         {
                             txtIDCard.Text = user.UserCode;
                             txtIDCard.Enabled = false;
                             //txtBirthday.Text = common.getBirthdyFromIDCard(user.UserCode);
                             hiddentxtBirthday.Value = common.getBirthdyFromIDCard(user.UserCode);
                             //txtBirthday.Enabled = false;
                             drpGender.SelectedValue = common.getGenderByIDCard(user.UserCode);
                             drpGender.Enabled = false;
                         }
                     }
                }
                trPPT.Visible = SysConfigClass.IsAllowUploadPPT();
                if (PageType != null && ID != null && PageType == "edit" && ID.Trim().Length != 0)
                {
                    hidePageType.Value = PageType;
                    hiddeApplyID.Value = ID;
                    FillForm(ID);
                    
                }
            }
        }

        #region <<   For Edit  >>
        public void FillForm(string ID)
        {
            DataSet dstApply = ApplyClass.getApplyByID(ID);
            if (dstApply.Tables[0].Rows.Count > 0)
            {
                #region  <<  基本信息  >>
                txtApplyName.Text = dstApply.Tables[0].Rows[0]["Apply_Name"].ToString();
                drpGender.SelectedValue = dstApply.Tables[0].Rows[0]["Gender"].ToString().Trim();
                txtMobile.Text = dstApply.Tables[0].Rows[0]["ApplyMobile"].ToString().Trim();
                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["Birthday"].ToString()))
                {
                    //txtBirthday.Text = Convert.ToDateTime(dstApply.Tables[0].Rows[0]["Birthday"].ToString().Trim()).ToString("yyyy-MM");
                    hiddentxtBirthday.Value = Convert.ToDateTime(dstApply.Tables[0].Rows[0]["Birthday"].ToString().Trim()).ToString("yyyy-MM");
                }
                //ApplyImgs.Value = dstApply.Tables[0].Rows[0]["ApplyImage"].ToString().Trim();
                //if (!string.IsNullOrEmpty(ApplyImgs.Value))
                //{
                //    panelUploadPhoto.Visible = false;
                //    panelShowPhoto.Visible = true;
                //    imgPhoto.ImageUrl = common.getAppSetting("FolderforLoadPath") + "/" +dstApply.Tables[0].Rows[0]["ApplyPeriodID"].ToString().Trim()+"/"+ ApplyImgs.Value;
                //}
                hiddenPPTFile.Value = dstApply.Tables[0].Rows[0]["ApplyPPT"].ToString().Trim();

                if (!string.IsNullOrEmpty(hiddenPPTFile.Value))
                {
                    ShowPPT.Visible = true;
                    string strNavigateurl = common.getAppSetting("FolderforLoadPath") + "/" + dstApply.Tables[0].Rows[0]["ApplyPeriodID"].ToString().Trim() + "/" + hiddenPPTFile.Value;
                    WebRequest web = WebRequest.Create(strNavigateurl);
                    if(web.ContentLength>0)

                    ShowPPT.NavigateUrl  = strNavigateurl;
                }

                txtIDCard.Text = dstApply.Tables[0].Rows[0]["IDCard"].ToString().Trim();
                drpApplyStyle.SelectedValue = dstApply.Tables[0].Rows[0]["ApplyStyle"].ToString().Trim();
                drpApplyStyle_SelectedIndexChanged(null, null);
                drpSubject.SelectedValue = dstApply.Tables[0].Rows[0]["SubjectID"].ToString().Trim();
                drpSubject_SelectedIndexChanged(null, null);
                
                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["GovernID"].ToString().Trim()))
                    drpGovern.SelectedValue = dstApply.Tables[0].Rows[0]["GovernID"].ToString().Trim();
                drpGovern_SelectedIndexChanged(null, null);
                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["UnitID"].ToString().Trim()))
                    drpUnit.SelectedValue = dstApply.Tables[0].Rows[0]["UnitID"].ToString().Trim();
                drpEducation.SelectedValue = dstApply.Tables[0].Rows[0]["EducationLevel"].ToString().Trim();

                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["GraduationDate"].ToString()))
                    txtGraduationTime.Text = Convert.ToDateTime(dstApply.Tables[0].Rows[0]["GraduationDate"].ToString().Trim()).ToString("yyyy-MM");

                txtGraduationSchool.Text = dstApply.Tables[0].Rows[0]["School"].ToString().Trim();
                string jobRankLevel = OtherClass.getJobRankLevelByJobRanK(dstApply.Tables[0].Rows[0]["CurrentJobRankID"].ToString().Trim());
                drpCurrentJobRank.SelectedValue = dstApply.Tables[0].Rows[0]["CurrentJobRankID"].ToString().Trim() + "," + jobRankLevel;
                //drpCurrentJobRank_SelectedIndexChanged(null, null);
                //BindApplyJobRank("");

                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["JobDate"].ToString()))
                    txtGetJobRankTime.Text = Convert.ToDateTime(dstApply.Tables[0].Rows[0]["JobDate"].ToString().Trim()).ToString("yyyy-MM");

                txtEmploymentLife.Text = dstApply.Tables[0].Rows[0]["JobTerm"].ToString().Trim();

                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["ConversionDate"].ToString()))
                    txtConversionDate.Text = Convert.ToDateTime(dstApply.Tables[0].Rows[0]["ConversionDate"].ToString().Trim()).ToString("yyyy-MM");

                drpApplyJobRank.SelectedValue = dstApply.Tables[0].Rows[0]["JobRankID"].ToString().Trim();
                
                drpSpeciality.SelectedValue = dstApply.Tables[0].Rows[0]["SpecialityID"].ToString().Trim();
                drpApplyStatus.SelectedValue = dstApply.Tables[0].Rows[0]["ApplyType"].ToString().Trim();
                drpPeriod.SelectedValue = dstApply.Tables[0].Rows[0]["ApplyPeriodID"].ToString().Trim();
                drpRegularJob.SelectedValue = dstApply.Tables[0].Rows[0]["FixedJob"].ToString().Trim();
                drpLanguage.SelectedValue = dstApply.Tables[0].Rows[0]["ForeignLanguageName"].ToString().Trim();
                drpLanguageLevel.SelectedValue = dstApply.Tables[0].Rows[0]["ForeignLanguageResult"].ToString().Trim();
                drpComputerLevel.SelectedValue = dstApply.Tables[0].Rows[0]["ComputerResult"].ToString().Trim();
                txtjobResult.Text = dstApply.Tables[0].Rows[0]["JobResult"].ToString().Trim();
                txtPoliticalResult.Text = dstApply.Tables[0].Rows[0]["PoliticsResult"].ToString().Trim();
                drpApplyplight.SelectedValue = dstApply.Tables[0].Rows[0]["Applyplight"].ToString().Trim();
                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["LastApplyDate"].ToString()))
                    txtLastApplyTime.Text = dstApply.Tables[0].Rows[0]["LastApplyDate"].ToString().Trim();

                txtSpecialityName.Text = dstApply.Tables[0].Rows[0]["SpecialityName"].ToString().Trim();

                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["SpecialitDateTime"].ToString()))
                    txtSpecialityEndTime.Text = Convert.ToDateTime(dstApply.Tables[0].Rows[0]["SpecialitDateTime"].ToString().Trim()).ToString("yyyy-MM") ;

                drpSpecialityLevel.SelectedValue = dstApply.Tables[0].Rows[0]["SpecialityLevel"].ToString().Trim();
                txtSpecialitapproveUnit.Text = dstApply.Tables[0].Rows[0]["SpecialitapproveUnit"].ToString().Trim();
                drpSpecialitPersonalRank.Text = dstApply.Tables[0].Rows[0]["SpecialitPersonalRank"].ToString().Trim();
                txtAwardsName.Text = dstApply.Tables[0].Rows[0]["AwardsName"].ToString().Trim();
                txtAwardsDateTime.Text = dstApply.Tables[0].Rows[0]["AwardsDateTime"].ToString().Trim();
                drpAwardsLevel.SelectedValue = dstApply.Tables[0].Rows[0]["AwardsLevel"].ToString().Trim();
                drpAwardsRank.SelectedValue = dstApply.Tables[0].Rows[0]["AwardsRank"].ToString().Trim();
                txtAwardsPersonal.Text = dstApply.Tables[0].Rows[0]["AwardsPersonalRank"].ToString().Trim();
                txtSpecialityName1.Text = dstApply.Tables[0].Rows[0]["SpecialityName1"].ToString().Trim();

                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["SpecialitDateTime1"].ToString()))
                    txtSpecialityEndTime1.Text = Convert.ToDateTime(dstApply.Tables[0].Rows[0]["SpecialitDateTime1"].ToString().Trim()).ToString("yyyy-MM");

                drpSpecialityLevel1.SelectedValue = dstApply.Tables[0].Rows[0]["SpecialityLevel1"].ToString().Trim();
                txtSpecialitapproveUnit1.Text = dstApply.Tables[0].Rows[0]["SpecialitapproveUnit1"].ToString().Trim();
                drpSpecialitPersonalRank1.Text = dstApply.Tables[0].Rows[0]["SpecialitPersonalRank1"].ToString().Trim();
                txtAwardsName1.Text = dstApply.Tables[0].Rows[0]["AwardsName1"].ToString().Trim();
                txtAwardsDateTime1.Text = dstApply.Tables[0].Rows[0]["AwardsDateTime1"].ToString().Trim();
                drpAwardsLevel1.SelectedValue = dstApply.Tables[0].Rows[0]["AwardsLevel1"].ToString().Trim();
                drpAwardsRank1.SelectedValue = dstApply.Tables[0].Rows[0]["AwardsRank1"].ToString().Trim();
                txtAwardsPersonal1.Text = dstApply.Tables[0].Rows[0]["AwardsPersonalRank1"].ToString().Trim();
                drpApplyJobRank_SelectedIndexChanged(null, null);
                #endregion
               
                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["ApplyID"].ToString().Trim()))
                {
                    #region << ApplyPublicity  >>
                    DataSet dstApplyPublicity = ApplyClass.dstApplyPublicity(dstApply.Tables[0].Rows[0]["ApplyID"].ToString().Trim());
                    if (dstApplyPublicity.Tables.Count > 0 && dstApplyPublicity.Tables[0].Rows.Count > 0)
                    {
                        drpStartShowMonth.SelectedValue = dstApplyPublicity.Tables[0].Rows[0]["startmonth"].ToString().Trim();
                        drpStartShowDay.SelectedValue = dstApplyPublicity.Tables[0].Rows[0]["startday"].ToString().Trim();
                        drpEndShowMonth.SelectedValue = dstApplyPublicity.Tables[0].Rows[0]["endmonth"].ToString().Trim();
                        drpEndShowDay.SelectedValue = dstApplyPublicity.Tables[0].Rows[0]["endday"].ToString().Trim();
                        txtShowAddress.Text = dstApplyPublicity.Tables[0].Rows[0]["address"].ToString().Trim();
                        drpShowResponse.SelectedValue = dstApplyPublicity.Tables[0].Rows[0]["response"].ToString().Trim();
                    }
                    #endregion

                    #region <<  论文绑定 >>
                    DataSet dstThesis = ApplyClass.dstThesis(dstApply.Tables[0].Rows[0]["ApplyID"].ToString().Trim());
                    int icount1 = 1;
                    int icount2 = 1;
                    int icount3 = 1;
                    int icount4 = 1;
                    string FileFullPath = common.getAppSetting("FolderforLoadPath") + "/" + dstApply.Tables[0].Rows[0]["ApplyPeriodID"].ToString().Trim()+"/";
                    foreach (DataRow drThesis in dstThesis.Tables[0].Rows)
                    {
                        switch (drThesis["SeqID"].ToString())
                        {
                            case "1":
                                {
                                    txtPaperTitle1.Text = drThesis["ThesisTitle"].ToString();
                                    txtJournalsNo1.Text = drThesis["JournalsNo"].ToString();
                                    hiddenFilePaper1.Value = drThesis["PagersPrint"].ToString();
                                    txtPeriodicalNo1.Text = drThesis["PeriodicalNo"].ToString().Trim();
                                    if (!string.IsNullOrEmpty(drThesis["PagersPrint"].ToString()))
                                    {
                                        string[] arrPagerImgs = drThesis["PagersPrint"].ToString().Split(new char[] { ';' });
                                        foreach (string pagerImgs in arrPagerImgs)
                                        {
                                            if (pagerImgs.Trim().Length > 0)
                                            {
                                                //if (icount1 == 1)
                                                //    this.showLink1.HRef = FileFullPath + pagerImgs;
                                                //else
                                                //{
                                                //    this.spanImgList1.InnerHtml += "<a href='" + FileFullPath + pagerImgs + "' class='zoom' rel='group'></a>";
                                                //}
                                                ////WebRequest web = WebRequest.Create(FileFullPath + pagerImgs);
                                                ////if (web.ContentLength > 0)
                                                //ShowPaper1.Visible = true;
                                                icount1++;
                                            }
                                        }
                                    }
                                    break;
                                }
                            case "2":
                                {
                                    txtPaperTitle2.Text = drThesis["ThesisTitle"].ToString();
                                    txtJournalsNo2.Text = drThesis["JournalsNo"].ToString();
                                    hiddenFilePaper2.Value = drThesis["PagersPrint"].ToString();
                                    txtPeriodicalNo2.Text = drThesis["PeriodicalNo"].ToString().Trim();
                                    if (!string.IsNullOrEmpty(drThesis["PagersPrint"].ToString()))
                                    {
                                        string[] arrPagerImgs = drThesis["PagersPrint"].ToString().Split(new char[] { ';' });
                                        foreach (string pagerImgs in arrPagerImgs)
                                        {
                                            if (pagerImgs.Trim().Length > 0)
                                            {
                                                //if (icount2 == 1)
                                                //    this.showLink2.HRef = FileFullPath +  pagerImgs;
                                                //else
                                                //{
                                                //    this.spanImgList2.InnerHtml += "<a href='" + FileFullPath +  pagerImgs + "' class='zoom' rel='group'></a>";
                                                //}
                                                //ShowPaper2.Visible = true;
                                                icount2++;
                                            }
                                        }
                                    }
                                    break;
                                }
                            case "3":
                                {
                                    txtPaperTitle3.Text = drThesis["ThesisTitle"].ToString();
                                    txtJournalsNo3.Text = drThesis["JournalsNo"].ToString();
                                    hiddenFilePaper3.Value = drThesis["PagersPrint"].ToString();
                                    txtPeriodicalNo3.Text = drThesis["PeriodicalNo"].ToString().Trim();
                                    if (!string.IsNullOrEmpty(drThesis["PagersPrint"].ToString()))
                                    {
                                        string[] arrPagerImgs = drThesis["PagersPrint"].ToString().Split(new char[] { ';' });
                                        foreach (string pagerImgs in arrPagerImgs)
                                        {
                                            if (pagerImgs.Trim().Length > 0)
                                            {
                                                //if (icount3 == 1)
                                                //    this.showLink3.HRef = FileFullPath +  pagerImgs;
                                                //else
                                                //{
                                                //    this.spanImgList3.InnerHtml += "<a href='" + FileFullPath +  pagerImgs + "' class='zoom' rel='group'></a>";
                                                //}
                                                //ShowPaper3.Visible = true;
                                                icount3++;
                                            }
                                        }
                                    }
                                    break;
                                }
                            case "4":
                                {
                                    //txtPaperTitle4.Text = drThesis["ThesisTitle"].ToString();
                                    //txtJournalsNo4.Text = drThesis["JournalsNo"].ToString();
                                    //hiddenFilePaper4.Value = drThesis["PagersPrint"].ToString();
                                    //txtPeriodicalNo4.Text = drThesis["PeriodicalNo"].ToString().Trim();
                                    //if (!string.IsNullOrEmpty(drThesis["PagersPrint"].ToString()))
                                    //{
                                    //    string[] arrPagerImgs = drThesis["PagersPrint"].ToString().Split(new char[] { ';' });
                                    //    foreach (string pagerImgs in arrPagerImgs)
                                    //    {
                                    //        if (pagerImgs.Trim().Length > 0)
                                    //        {
                                    //            //if (icount4 == 1)
                                    //            //    this.showLink4.HRef = FileFullPath +  pagerImgs;
                                    //            //else
                                    //            //{
                                    //            //    this.spanImgList4.InnerHtml += "<a href='" + FileFullPath +pagerImgs + "' class='zoom' rel='group'></a>";
                                    //            //}
                                    //            //ShowPaper4.Visible = true;
                                    //            icount4++;
                                    //        }
                                    //    }
                                    //}
                                    break;
                                }
                            default:
                                break;
                        }
                    }
                    #endregion
                }
                
            }
        }
        #endregion

        #region <<  申报年度  >>
        public void BindPeriod()
        {
            //DataSet dst = PeriodClass.getAperiod();
            //foreach (DataRow dr in dst.Tables[0].Rows)
            //{
                ListItem li = new ListItem((string)Session["ApplyPeriod"], (string)Session["ApplyPeriod"]);
                drpPeriod.Items.Add(li);
           // }
        }
        #endregion

        #region <<  申报职称  >>
        public void BindCurrentJobRank()
        {
            DataSet dst = OtherClass.getJobRank();
            drpCurrentJobRank.Items.Add(new ListItem("请选择","-1"));
            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                ListItem li = new ListItem(dr["JobRankName"].ToString(), dr["JobRankID"].ToString() + "," + dr["JobRankLevel"].ToString());
                drpCurrentJobRank.Items.Add(li);
            }
        }

        public void BindApplyJobRank(string JobRankLevel)
        {
            drpApplyJobRank.Items.Clear();
            DataSet dst = OtherClass.getJobRank();//OtherClass.getJobRank(JobRankLevel);
            drpApplyJobRank.Items.Add(new ListItem("请选择", "-1"));
            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                ListItem li = new ListItem(dr["JobRankName"].ToString(), dr["JobRankID"].ToString());
                drpApplyJobRank.Items.Add(li);
            }
        }

        protected void drpCurrentJobRank_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.drpCurrentJobRank.SelectedValue != "-1")
            {
                string CurrentJobRankLevel = this.drpCurrentJobRank.SelectedValue.ToString().Split(new char[] { ',' })[1].ToString();
                BindApplyJobRank(CurrentJobRankLevel);
            }
        }

        #endregion

        #region <<  绑定申请学科组和专业  >>

        protected void drpApplyStyle_SelectedIndexChanged(object sender, EventArgs e)
        {
            string level = drpApplyStyle.SelectedValue;
            SubjectBind(level);
            drpSpeciality.Items.Clear();
            ListItem li1 = new ListItem("请选择专业", "-1");
            this.drpSpeciality.Items.Add(li1);
        }

        public void SubjectBind(string level)
        {
            this.drpSubject.Items.Clear();
            DataSet dst = Subject.getSujectByApplyStyle(level);
            ListItem li1 = new ListItem("请选择学科组", "-1");
            this.drpSubject.Items.Add(li1);
            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                if (dr["SubjectID"].ToString().Length > 0)
                {
                    ListItem li = new ListItem(dr["SubjectName"].ToString(), dr["SubjectID"].ToString());
                    this.drpSubject.Items.Add(li);
                }
            }
        }

        protected void drpSubject_SelectedIndexChanged(object sender, EventArgs e)
        {
            string strSubjectID = drpSubject.SelectedValue;
            if (strSubjectID != "-1")
            {
                SpecialityBind(strSubjectID);
            }
            else
            {
                drpSpeciality.Items.Clear();
                ListItem li1 = new ListItem("请选择专业", "-1");
                this.drpSpeciality.Items.Add(li1);
            }
        }

        public void SpecialityBind(string SubjectID)
        {
            drpSpeciality.Items.Clear();
            ListItem li1 = new ListItem("请选择专业", "-1");
            this.drpSpeciality.Items.Add(li1);
            DataSet dst = Subject.getAllSpecialityBySubjectID(SubjectID);
            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                ListItem li = new ListItem(dr["SpecialityName"].ToString(), dr["SpecialityID"].ToString() );
                this.drpSpeciality.Items.Add(li);
            }
        }

        #endregion

        #region <<  主管局和工作单位绑定  >>

        public void UnitGovernBind(string GovernID)
        {
            drpGovern.Items.Clear();
            DataSet dstGovern = null;
            ListItem list = new ListItem("请选择主管局", "-1");
            drpGovern.Items.Add(list);
            dstGovern = UnitClass.getGovernByGovernID(GovernID);
            
            if (dstGovern.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow row in dstGovern.Tables[0].Rows)
                {
                    if (row["GovernID"].ToString().Trim().Length !=0)
                    {
                        ListItem li = new ListItem(row["GovernName"].ToString(), row["GovernID"].ToString());
                        this.drpGovern.Items.Add(li);
                        //this.bindDropChildItem(row["GovernID"].ToString());
                    }
                }
            }
        }

        protected void drpGovern_SelectedIndexChanged(object sender, EventArgs e)
        {
            string strGovernSelected = drpGovern.SelectedValue;
            if (strGovernSelected != "-1")
            {
                string GovernID = strGovernSelected;
                bindDropChildItem(GovernID);
            }
            else
            {
                drpUnit.Items.Clear();
                ListItem list = new ListItem("请选择工作单位", "-1");
                drpUnit.Items.Add(list);
            }
        }

        public void bindDropChildItem(string GovernID)
        {
            drpUnit.Items.Clear();
            ListItem list = new ListItem("请选择工作单位","-1");
            drpUnit.Items.Add(list);
            DataSet dstUnit = UnitClass.getUnitByGovern(GovernID);
            foreach(DataRow  dr in dstUnit.Tables[0].Rows)
            {
                drpUnit.Items.Add(new ListItem(dr["UnitName"].ToString(), dr["UnitID"].ToString()));
            }
        }

        public void UnitDropBind(string UnitID, string GovernID)
        {
            drpUnit.Items.Clear();
            drpGovern.Items.Clear();
            string strUnitName = UnitClass.getUnitName(UnitID);
            ListItem li = new ListItem(strUnitName, UnitID);
            drpUnit.Items.Add(li);
            string strGovernName = UnitClass.GetGovernName(GovernID);
            ListItem liGovern = new ListItem(strGovernName, GovernID);
            drpGovern.Items.Add(liGovern);
        }

        #endregion

        #region <<  绑定下拉菜单项  >>

        public void BindTogether()
        {
            BindApplyType();
            BindComputerResult();
            Bindeducationlevel();
            BindFixedJob();
            BindSpecialityLevel();
            BindSpecialityLevel1();
            BindForeignLanguageResult();
            BindGender();
            BindAwardsLevel();
            BindAwardsRank();
            BindSpecialitPersonalRank();
            BindAwardsLevel1();
            BindAwardsRank1();
            BindSpecialitPersonalRank1();
            BindApplyStyle();
            BindStartAndEndMonth();
            BindStartAndEndDay();
        }

        public void LanguageBInd()
        {
            DataSet dst = OtherClass.getLanguageType();
            drpLanguage.Items.Add(new ListItem("请选择", "-1"));
            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                ListItem li = new ListItem(dr["ForeignLanguageName"].ToString(), dr["ForeignLanguageid"].ToString());
                drpLanguage.Items.Add(li);
            }
        }

        public void BindApplyType()
        {
            DataSet dst = OtherClass.dstgetApplyType();
            BindDropDownList(drpApplyStatus, dst);
        }

        public void BindComputerResult()
        {
            DataSet dst = OtherClass.dstGetComputerResult();
            BindDropDownList(drpComputerLevel, dst);
        }

        public void Bindeducationlevel()
        {
            DataSet dst = OtherClass.dstGeteducationlevel();
            BindDropDownList(drpEducation, dst);
        }

        public void BindFixedJob()
        {
            DataSet dst = OtherClass.dstGetFixedJob();
            BindDropDownList(drpRegularJob, dst);
        }

        public void BindSpecialityLevel()
        {
            DataSet dst = OtherClass.dstGetSpecialityLevel();
            drpSpecialityLevel.Items.Clear();
            ListItem firstItem = new ListItem("请选择", "0");
            drpSpecialityLevel.Items.Add(firstItem);
            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                ListItem itemlist = new ListItem(dr["dict_Display"].ToString(), dr["dict_Value"].ToString());
                if (dr["dict_Value"].ToString() == "0")
                    itemlist.Selected = true;
                drpSpecialityLevel.Items.Add(itemlist);
            }
            //BindDropDownList(drpSpecialityLevel, dst);
        }


        public void BindSpecialityLevel1()
        {
            DataSet dst = OtherClass.dstGetSpecialityLevel();
            drpSpecialityLevel1.Items.Clear();
            ListItem firstItem = new ListItem("请选择", "0");
            drpSpecialityLevel1.Items.Add(firstItem);
            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                ListItem itemlist = new ListItem(dr["dict_Display"].ToString(), dr["dict_Value"].ToString());
                if (dr["dict_Value"].ToString() == "0")
                    itemlist.Selected = true;
                drpSpecialityLevel1.Items.Add(itemlist);
            }
            //BindDropDownList(drpSpecialityLevel, dst);
        }

        public void BindForeignLanguageResult()
        {
            DataSet dst = OtherClass.dstGetForeignLanguageResult();
           
            BindDropDownList(drpLanguageLevel, dst);
        }

        public void BindGender()
        {
            DataSet dst = OtherClass.dstGetGender();
            BindDropDownList(drpGender, dst);
        }

        public void BindAwardsLevel()
        {
            DataSet dst = OtherClass.dstGetAwardsLevel();
            drpAwardsLevel.Items.Clear();
            ListItem firstItem = new ListItem("请选择", "0");
            drpAwardsLevel.Items.Add(firstItem);
            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                ListItem itemlist = new ListItem(dr["dict_Display"].ToString(), dr["dict_Value"].ToString());
                if (dr["dict_Value"].ToString() == "0")
                    itemlist.Selected = true;
                drpAwardsLevel.Items.Add(itemlist);
            }
            //BindDropDownList(drpAwardsLevel, dst);
        }

        public void BindAwardsLevel1()
        {
            DataSet dst = OtherClass.dstGetAwardsLevel();
            drpAwardsLevel1.Items.Clear();
            ListItem firstItem = new ListItem("请选择", "0");
            drpAwardsLevel1.Items.Add(firstItem);
            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                ListItem itemlist = new ListItem(dr["dict_Display"].ToString(), dr["dict_Value"].ToString());
                if (dr["dict_Value"].ToString() == "0")
                    itemlist.Selected = true;
                drpAwardsLevel1.Items.Add(itemlist);
            }
            //BindDropDownList(drpAwardsLevel, dst);
        }

        public void BindAwardsRank()
        {
            DataSet dst = OtherClass.dstGetAwardsRank();
            drpAwardsRank.Items.Clear();
            ListItem firstItem = new ListItem("请选择", "0");
            drpAwardsRank.Items.Add(firstItem);
            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                ListItem itemlist = new ListItem(dr["dict_Display"].ToString(), dr["dict_Value"].ToString());
                if (dr["dict_Value"].ToString() == "0")
                    itemlist.Selected = true;
                drpAwardsRank.Items.Add(itemlist);
            }
            //BindDropDownList(drpAwardsRank, dst);
        }

        public void BindAwardsRank1()
        {
            DataSet dst = OtherClass.dstGetAwardsRank();
            drpAwardsRank1.Items.Clear();
            ListItem firstItem = new ListItem("请选择", "0");
            drpAwardsRank1.Items.Add(firstItem);
            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                ListItem itemlist = new ListItem(dr["dict_Display"].ToString(), dr["dict_Value"].ToString());
                if (dr["dict_Value"].ToString() == "0")
                    itemlist.Selected = true;
                drpAwardsRank1.Items.Add(itemlist);
            }
            //BindDropDownList(drpAwardsRank, dst);
        }

        public void BindSpecialitPersonalRank()
        {
            DataSet dst = OtherClass.dstGetSpecialitPersonalRank();
            drpSpecialitPersonalRank.Items.Clear();
            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                ListItem itemlist = new ListItem(dr["dict_Display"].ToString(), dr["dict_Value"].ToString());
                if (dr["dict_Value"].ToString() == "0")
                    itemlist.Selected = true;
                drpSpecialitPersonalRank.Items.Add(itemlist);
            }
            //BindDropDownList(drpSpecialitPersonalRank, dst);
        }

        public void BindSpecialitPersonalRank1()
        {
            DataSet dst = OtherClass.dstGetSpecialitPersonalRank();
            drpSpecialitPersonalRank1.Items.Clear();
            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                ListItem itemlist = new ListItem(dr["dict_Display"].ToString(), dr["dict_Value"].ToString());
                if (dr["dict_Value"].ToString() == "0")
                    itemlist.Selected = true;
                drpSpecialitPersonalRank1.Items.Add(itemlist);
            }
            //BindDropDownList(drpSpecialitPersonalRank, dst);
        }

        public void BindApplyStyle()
        {
            DataSet dst = OtherClass.dstGetApplyStyle();
            BindDropDownList(drpApplyStyle, dst);
        }

        public void BindDropDownList(ListControl Controls,DataSet dst)
        { 
            Controls.Items.Clear();
            ListItem list = new ListItem("请选择","-1");
            Controls.Items.Add(list);
            foreach(DataRow dr in dst.Tables[0].Rows)
            {
                ListItem itemlist = new ListItem(dr["dict_Display"].ToString(), dr["dict_Value"].ToString());
                Controls.Items.Add(itemlist);
            }
        }

        public void BindStartAndEndMonth()
        {
            for (int i = 1; i <= 12; i++)
            {
                ListItem listStart;
                ListItem listEnd;
                if (i < 10)
                {
                    listStart = new ListItem("0" + i.ToString(), "0" + i.ToString());
                    listEnd = new ListItem("0" + i.ToString(), "0" + i.ToString());
                }
                else
                {
                    listStart = new ListItem(i.ToString(), i.ToString());
                    listEnd = new ListItem(i.ToString(), i.ToString());
                }
                drpStartShowMonth.Items.Add(listStart);
                drpEndShowMonth.Items.Add(listEnd);
            }
        }

        public void BindStartAndEndDay()
        {
            for (int i = 1; i <= 31; i++)
            {
                ListItem listStart;
                ListItem listEnd;
                if (i < 10)
                {
                    listStart = new ListItem("0" + i.ToString(), "0" + i.ToString());
                    listEnd = new ListItem("0" + i.ToString(), "0" + i.ToString());
                }
                else
                {
                    listStart = new ListItem(i.ToString(), i.ToString());
                    listEnd = new ListItem(i.ToString(), i.ToString());
                }
                drpStartShowDay.Items.Add(listStart);
                drpEndShowDay.Items.Add(listEnd);
            }
        }

        #endregion

        #region <<  保存PPT  >>
        protected void butSavePPT_Click(object sender, EventArgs e)
        {
            if (txtIDCard.Text.Trim().Length > 0 && drpPeriod.SelectedValue.Trim().Length>0)
            {
                
                string strFullFolderPath = common.getAppSetting("FolderforSavePath") + "\\" + drpPeriod.SelectedValue.Trim();
                string LoadFullPath = common.getAppSetting("FolderforLoadPath") + "/" + drpPeriod.SelectedValue.Trim();
                common.CreateFolder(strFullFolderPath);
                HttpFileCollection hfc = Request.Files;
                for (int i = 0; i < hfc.Count; i++)
                {
                    if (hfc.Keys[i].ToLower().Trim() == "fileppt")
                    {
                        HttpPostedFile hpf = hfc[i];
                        if (hpf.ContentLength > 0)
                        {
                            string FileFullPath = strFullFolderPath + "\\" + txtIDCard.Text.Trim()+ System.IO.Path.GetExtension(hpf.FileName);
                            if (File.Exists(FileFullPath))
                            {
                                File.Delete(FileFullPath);
                            }
                            hpf.SaveAs(FileFullPath);
                            string LoadPath = LoadFullPath + "/" + txtIDCard.Text.Trim()+ System.IO.Path.GetExtension(hpf.FileName);
                            hiddenPPTFile.Value = txtIDCard.Text.Trim() + System.IO.Path.GetExtension(hpf.FileName);
                            ShowPPT.Visible = true;
                            ShowPPT.NavigateUrl = LoadPath;
                        }
                    }
                }
            }
        }
        #endregion

        #region  <<  保存扫描文件  >>

        protected void butSavePaperImg_Click(object sender, EventArgs e)
        {
            int icount1 = 1;
            int icount2 = 1;
            int icount3 = 1;
            int icount4 = 1;
            try
            {
                if (txtIDCard.Text.Trim().Length > 0 && drpPeriod.SelectedValue.Trim().Length > 0)
                {
                    string strFullFolderPath = common.getAppSetting("FolderforSavePath") + "\\" + drpPeriod.SelectedValue.Trim();
                    string LoadFullPath = common.getAppSetting("FolderforLoadPath") + "/" + drpPeriod.SelectedValue.Trim();
                    common.CreateFolder(strFullFolderPath);
                    HttpFileCollection hfc = Request.Files;
                    for (int i = 0; i < hfc.Count; i++)
                    {
                        string FileControlName = hfc.Keys[i].ToString();
                        switch (FileControlName)
                        {
                            case "filePaper1":
                                {
                                    HttpPostedFile hpf = hfc[i];
                                    if (hpf.ContentLength > 0)
                                    {
                                        string FileFullPath = strFullFolderPath + "\\" + txtIDCard.Text.Trim() + "_Thesis1_" + icount1 + System.IO.Path.GetExtension(hpf.FileName);
                                        if (File.Exists(FileFullPath))
                                        {
                                            File.Delete(FileFullPath);
                                        }
                                        hpf.SaveAs(FileFullPath);
                                        string LoadPath = LoadFullPath +"/"+txtIDCard.Text.Trim() + "_Thesis1_" + icount1 + System.IO.Path.GetExtension(hpf.FileName);
                                        //if (icount1 == 1)
                                        //    this.showLink1.HRef = LoadPath;
                                        //else
                                        //{
                                        //    this.spanImgList1.InnerHtml += "<a href='" + LoadPath + "' class='zoom' rel='group'></a>";
                                        //}
                                        //hiddenFilePaper1.Value += txtIDCard.Text.Trim() + "_Thesis1_" + icount1 + System.IO.Path.GetExtension(hpf.FileName) + ";";
                                        //ShowPaper1.Visible = true;
                                        icount1++;
                                    }
                                    break;
                                }
                            case "filePaper2":
                                {
                                    HttpPostedFile hpf = hfc[i];
                                    if (hpf.ContentLength > 0)
                                    {
                                        string FileFullPath = strFullFolderPath + "\\" + txtIDCard.Text.Trim() + "_Thesis2_" + icount2 + System.IO.Path.GetExtension(hpf.FileName);
                                        if (File.Exists(FileFullPath))
                                        {
                                            File.Delete(FileFullPath);
                                        }
                                        hpf.SaveAs(FileFullPath);
                                        //string LoadPath = LoadFullPath + "/" + txtIDCard.Text.Trim() + "_Thesis2_" + icount2 + System.IO.Path.GetExtension(hpf.FileName);
                                        //if (icount2 == 1)
                                        //    this.showLink2.HRef = LoadFullPath;
                                        //else
                                        //{
                                        //    this.spanImgList2.InnerHtml += "<a href='" + LoadFullPath + "' class='zoom' rel='group'></a>";
                                        //}
                                        //hiddenFilePaper2.Value += txtIDCard.Text.Trim() + "_Thesis2_" + icount2 + System.IO.Path.GetExtension(hpf.FileName) + ";";
                                        //ShowPaper2.Visible = true;
                                        icount2++;
                                    }
                                    break;
                                }
                            case "filePaper3":
                                {
                                    HttpPostedFile hpf = hfc[i];
                                    if (hpf.ContentLength > 0)
                                    {
                                        string FileFullPath = strFullFolderPath + "\\" + txtIDCard.Text.Trim() + "_Thesis3_" + icount3 + System.IO.Path.GetExtension(hpf.FileName);
                                        if (File.Exists(FileFullPath))
                                        {
                                            File.Delete(FileFullPath);
                                        }
                                        hpf.SaveAs(FileFullPath);
                                        string LoadPath = LoadFullPath + "/" + txtIDCard.Text.Trim() + "_Thesis3_" + icount3 + System.IO.Path.GetExtension(hpf.FileName);
                                        //if (icount3 == 1)
                                        //    this.showLink3.HRef = LoadPath;
                                        //else
                                        //{
                                        //    this.spanImgList3.InnerHtml += "<a href='" + LoadPath + "' class='zoom' rel='group'></a>";
                                        //}
                                        //hiddenFilePaper3.Value += txtIDCard.Text.Trim() + "_Thesis3_" + icount3 + System.IO.Path.GetExtension(hpf.FileName) + ";";
                                        //ShowPaper3.Visible = true;
                                        icount3++;
                                    }
                                    break;
                                }
                            case "filePaper4":
                                {
                                    HttpPostedFile hpf = hfc[i];
                                    if (hpf.ContentLength > 0)
                                    {
                                        string FileFullPath = strFullFolderPath + "\\" + txtIDCard.Text.Trim() + "_Thesis4_" + icount4 + System.IO.Path.GetExtension(hpf.FileName);
                                        if (File.Exists(FileFullPath))
                                        {
                                            File.Delete(FileFullPath);
                                        }
                                        hpf.SaveAs(FileFullPath);
                                        //string LoadPath = LoadFullPath + "/" + txtIDCard.Text.Trim() + "_Thesis4_" + icount4 + System.IO.Path.GetExtension(hpf.FileName);
                                        //if (icount4 == 1)
                                        //    this.showLink4.HRef = LoadPath;
                                        //else
                                        //{
                                        //    this.spanImgList4.InnerHtml += "<a href='" + LoadPath + "' class='zoom' rel='group'></a>";
                                        //}
                                        //hiddenFilePaper4.Value += txtIDCard.Text.Trim() + "_Thesis4_" + icount4 + System.IO.Path.GetExtension(hpf.FileName)+ ";";
                                        //ShowPaper4.Visible = true;
                                        icount4++;
                                    }
                                    break;
                                }
                            default:
                                break;
                        }
                    }
                }
            }
            catch
            { 

            }
        }

        #endregion

        #region <<  保存申报  >>
        protected void butSave_Click(object sender, EventArgs e)
        {
            string strGovernID = drpGovern.SelectedValue;
            string strUnitID = drpUnit.SelectedValue;
            string CurrentJobRank = string.Empty;
            string ApplySpeciality = string.Empty;
            string ApplySubject = string.Empty;
            string strAge = string.Empty;

            int seqID1 = 0;
            int seqID2 = 0;
            int seqID3 = 0;
            int seqID4 = 0;


            int jobTerm = int.Parse(txtEmploymentLife.Text.Trim());

            //if (UnitGovern.IndexOf(",") > 0)
            //{
            //    string UnitType = UnitGovern.Split(new char[] { ',' })[1].ToString();
            //    if (UnitType == "G")
            //        strGovernID = UnitGovern.Split(new char[] { ',' })[0].ToString();
            //    else
            //    {
            //        strUnitID = UnitGovern.Split(new char[] { ',' })[0].ToString();
            //        strGovernID = UnitGovern.Split(new char[] { ',' })[1].ToString();
            //    }
            //}
            ApplySpeciality = drpSpeciality.SelectedValue;
            ApplySubject = drpSubject.SelectedValue;

            CurrentJobRank = drpCurrentJobRank.SelectedValue;
            if (CurrentJobRank.Trim().Length > 0)
                CurrentJobRank = CurrentJobRank.Split(new char[] { ',' })[0].ToString();
            if (txtPaperTitle1.Text.Trim().Length > 0 && txtJournalsNo1.Text.Trim().Length > 0)
                seqID1 = 1;
            if (txtPaperTitle2.Text.Trim().Length > 0 && txtJournalsNo2.Text.Trim().Length > 0)
                seqID2 = 2;
            if (txtPaperTitle3.Text.Trim().Length > 0 && txtJournalsNo3.Text.Trim().Length > 0)
                seqID3 = 3;
            //if (txtPaperTitle4.Text.Trim().Length > 0 && txtJournalsNo4.Text.Trim().Length > 0)
            //    seqID4 = 4;
            strAge = Convert.ToString(DateTime.Now.Year - common.changeDateFormatToDate(hiddentxtBirthday.Value.Trim()).Year);//(txtBirthday.Text.Trim()).Year);
            DataSet dstApply = new DataSet();
            if (hidePageType.Value != "edit")
                dstApply = ApplyClass.getApplyDataSetByIDCardAndPeriod(txtIDCard.Text, drpPeriod.SelectedValue);
            else
                dstApply.Tables.Add(new DataTable());
            if (dstApply.Tables[0].Rows.Count == 0)
            {
                ApplyBase AB = new ApplyBase();

                AB.Apply_Name = txtApplyName.Text.Trim();
                AB.UnitID = strUnitID;
                AB.GovernID = strGovernID;
                AB.Gender = drpGender.SelectedValue;
                //AB.ApplyImage = ApplyImgs.Value;
                AB.ApplyStyle = drpApplyStyle.SelectedValue;
                AB.age = strAge;
                AB.Birthday = hiddentxtBirthday.Value;//txtBirthday.Text.Trim();
                AB.EducationLevel = drpEducation.SelectedValue;
                AB.ApplyPeriodID = drpPeriod.SelectedValue;
                AB.IDCard = txtIDCard.Text;
                AB.School = txtGraduationSchool.Text;
                AB.ApplyMobile = txtMobile.Text;
                AB.GraduationDate = txtGraduationTime.Text;
                AB.CurrentJobRankID = CurrentJobRank;
                AB.ApplyType = drpApplyStatus.SelectedValue;
                AB.SpecialityID = ApplySpeciality;
                AB.JobRankID = drpApplyJobRank.SelectedValue;
                AB.SubjectID = ApplySubject;
                AB.JobDate = txtGetJobRankTime.Text;
                AB.ConversionDate = txtConversionDate.Text;
                AB.JobTerm = jobTerm;
                AB.FixedJob = drpRegularJob.SelectedValue;
                AB.ForeignLanguageName = drpLanguage.SelectedValue;
                AB.ForeignLanguageResult = drpLanguageLevel.SelectedValue;
                AB.PoliticsResult = txtPoliticalResult.Text;
                AB.JobResult = txtjobResult.Text.Trim();
                AB.ComputerResult = drpComputerLevel.SelectedValue;
                AB.Applyplight = drpApplyplight.SelectedValue;
                AB.ApplyPPT = hiddenPPTFile.Value;
                AB.LastApplyDate = txtLastApplyTime.Text;
                AB.SpecialityName = txtSpecialityName.Text;
                AB.SpecialityLevel = drpSpecialityLevel.SelectedValue;
                AB.SpecialitapproveUnit = txtSpecialitapproveUnit.Text;
                AB.SpecialitPersonalRank = drpSpecialitPersonalRank.SelectedValue;
                AB.SpecialitDateTime = txtSpecialityEndTime.Text;
                AB.Status = "A";
                AB.AwardsName = txtAwardsName.Text;
                AB.AwardsLevel = drpAwardsLevel.SelectedValue;
                AB.AwardsRank = drpAwardsRank.SelectedValue;
                AB.AwardsPersonalRank = txtAwardsPersonal.Text;
                AB.AwardsDateTime = txtAwardsDateTime.Text;
                AB.AwardsPersonalRank = txtAwardsPersonal.Text;


                AB.SpecialityName1 = txtSpecialityName1.Text;
                AB.SpecialityLevel1 = drpSpecialityLevel1.SelectedValue;
                AB.SpecialitapproveUnit1 = txtSpecialitapproveUnit1.Text;
                AB.SpecialitPersonalRank1 = drpSpecialitPersonalRank1.SelectedValue;
                AB.SpecialitDateTime1 = txtSpecialityEndTime1.Text;
                AB.AwardsName1 = txtAwardsName1.Text;
                AB.AwardsLevel1 = drpAwardsLevel1.SelectedValue;
                AB.AwardsRank1 = drpAwardsRank1.SelectedValue;
                AB.AwardsPersonalRank1 = txtAwardsPersonal1.Text;
                AB.AwardsDateTime1 = txtAwardsDateTime1.Text;
                AB.AwardsPersonalRank1 = txtAwardsPersonal1.Text;

                AB.SeqID1 = seqID1;
                AB.JournalsNo1 = txtJournalsNo1.Text;
                AB.ThesisTitle1 = txtPaperTitle1.Text;
                AB.PagersPrint1 = hiddenFilePaper1.Value;
                AB.PeriodicalNo1 = txtPeriodicalNo1.Text;
                AB.SeqID2 = seqID2;
                AB.JournalsNo2 = txtJournalsNo2.Text;
                AB.ThesisTitle2 = txtPaperTitle2.Text;
                AB.PagersPrint2 = hiddenFilePaper2.Value;
                AB.PeriodicalNo2 = txtPeriodicalNo2.Text;
                AB.SeqID3 = seqID3;
                AB.JournalsNo3 = txtJournalsNo3.Text;
                AB.ThesisTitle3 = txtPaperTitle3.Text;
                AB.PagersPrint3 = hiddenFilePaper3.Value;
                AB.PeriodicalNo3 = txtPeriodicalNo3.Text;
                AB.SeqID4 = seqID4;
                //AB.JournalsNo4 = txtJournalsNo4.Text;
                //AB.ThesisTitle4 = txtPaperTitle4.Text;
                //AB.PagersPrint4 = hiddenFilePaper4.Value;
                //AB.PeriodicalNo4 = txtPeriodicalNo4.Text;
                AB.startmonth=drpStartShowMonth.SelectedValue;
                AB.startday=drpStartShowDay.SelectedValue;
                AB.endmonth=drpEndShowMonth.SelectedValue;
                AB.endday=drpEndShowDay.SelectedValue;
                AB.address=txtShowAddress.Text;
                AB.response = drpShowResponse.SelectedValue;
                AB.DataEnteredUserID = ((BHUser)Session["user"]).UserID;

                if (hidePageType.Value != "" && hiddeApplyID != null && hiddeApplyID.Value.Trim().Length > 0 && hidePageType.Value == "edit")
                {
                    AB.ApplyID = hiddeApplyID.Value.Trim();
                    ApplyClass.ApplyUpdate(AB);
                }
                else
                {
                    ApplyClass.ApplySave(AB);
                }
                if (PageType != "edit")
                {
                    setFiledNull();
                }
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "confirmsave", "<script>alert('申报信息添加成功!');</script>");
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "confirm", "<script>alert('您申报 " + drpPeriod.SelectedValue + " 年度的身份证号为[" + txtIDCard.Text + "]评审信息,\r\n已经在数据库中存在,不能重复添加! ');</script>");
            }

        }
        #endregion

        public void setFiledNull()
        {
            txtApplyName.Text = string.Empty;
            drpGovern.SelectedValue = "-1";
            drpUnit.SelectedValue = "-1";
            drpGender.SelectedValue = "-1" ;

            //txtBirthday.Text = string.Empty;
            hiddentxtBirthday.Value = string.Empty;
            drpEducation.SelectedValue = "-1";

            txtIDCard.Text = string.Empty;
            txtGraduationSchool.Text = string.Empty;
            txtMobile.Text = string.Empty;
            txtGraduationTime.Text = string.Empty;
            drpCurrentJobRank.SelectedValue = "-1";
            drpApplyStatus.SelectedValue = "-1";
            drpSpeciality.SelectedValue = "-1";
            drpSubject.SelectedValue = "-1";
            drpApplyJobRank.SelectedValue = "-1";

            txtGetJobRankTime.Text = string.Empty;
            txtConversionDate.Text = string.Empty;
            txtEmploymentLife.Text = string.Empty;
            drpRegularJob.SelectedValue = "-1";
            drpLanguage.SelectedValue = "-1";
            drpLanguageLevel.SelectedValue = "-1";
            txtPoliticalResult.Text = string.Empty;
            txtjobResult.Text = string.Empty;
            drpComputerLevel.SelectedValue = "-1";
            drpApplyplight.SelectedValue = "F";
            hiddenPPTFile.Value = string.Empty;
            txtLastApplyTime.Text = string.Empty;
            txtSpecialityName.Text = string.Empty;
            drpSpecialityLevel.SelectedValue = "0";
            txtSpecialitapproveUnit.Text = string.Empty;
            drpSpecialitPersonalRank.SelectedValue = "0";
            txtSpecialityEndTime.Text = string.Empty;
            txtAwardsName.Text = string.Empty;
            drpAwardsLevel.SelectedValue = "0";
            drpAwardsRank.SelectedValue = "0";
            txtAwardsPersonal.Text = string.Empty;
            txtAwardsDateTime.Text = string.Empty;
            txtAwardsPersonal.Text = string.Empty;

            txtSpecialityName1.Text = string.Empty;
            drpSpecialityLevel1.SelectedValue = "0";
            txtSpecialitapproveUnit1.Text = string.Empty;
            drpSpecialitPersonalRank1.SelectedValue = "0";
            txtSpecialityEndTime1.Text = string.Empty;
            txtAwardsName1.Text = string.Empty;
            drpAwardsLevel1.SelectedValue = "0";
            drpAwardsRank1.SelectedValue = "0";
            txtAwardsPersonal1.Text = string.Empty;
            txtAwardsDateTime1.Text = string.Empty;
            txtAwardsPersonal1.Text = string.Empty;

            txtJournalsNo1.Text = string.Empty;
            txtPaperTitle1.Text = string.Empty;
            hiddenFilePaper1.Value = string.Empty;
            txtPeriodicalNo1.Text = string.Empty;

            txtJournalsNo2.Text = string.Empty;
            txtPaperTitle2.Text = string.Empty;
            hiddenFilePaper2.Value = string.Empty;
            txtPeriodicalNo2.Text = string.Empty;

            txtJournalsNo3.Text = string.Empty;
            txtPaperTitle3.Text = string.Empty;
            hiddenFilePaper3.Value = string.Empty;
            txtPeriodicalNo3.Text = string.Empty;

            //txtJournalsNo4.Text = string.Empty;
            //txtPaperTitle4.Text = string.Empty;
            //hiddenFilePaper4.Value = string.Empty;
            //txtPeriodicalNo4.Text = string.Empty;
            drpStartShowMonth.SelectedValue = "01";
            drpStartShowDay.SelectedValue = "01";
            drpEndShowMonth.SelectedValue = "01";
            drpEndShowDay.SelectedValue = "01";
            txtShowAddress.Text = string.Empty;
           drpShowResponse.SelectedValue = "0";
        }

        #region  <<  保存照片  >>
        //protected void butSaveImg_Click(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        if (txtIDCard.Text.Trim().Length > 0 && drpPeriod.SelectedValue.Trim().Length > 0)
        //        {
        //            string strFullFolderPath = common.getAppSetting("FolderforSavePath") + "\\" + drpPeriod.SelectedValue.Trim();
        //            string strLoadFolderPath = common.getAppSetting("FolderforLoadPath") + "/" + drpPeriod.SelectedValue.Trim() + "/";
        //            common.CreateFolder(strFullFolderPath);
        //            HttpFileCollection hfc = Request.Files;
        //            for (int i = 0; i < hfc.Count; i++)
        //            {
        //                if (hfc.Keys[i].ToString() == "UploadPhoto")
        //                {
        //                    HttpPostedFile hpf = hfc[i];
        //                    if (hpf.ContentLength > 0)
        //                    {
        //                        string FileFullPath = strFullFolderPath + "\\" + txtIDCard.Text.Trim() + System.IO.Path.GetExtension(hpf.FileName);
        //                        if (File.Exists(FileFullPath))
        //                        {
        //                            File.Delete(FileFullPath);
        //                        }
        //                        hpf.SaveAs(FileFullPath);
        //                        if (File.Exists(FileFullPath))
        //                        {
        //                            panelUploadPhoto.Visible = false;
        //                            panelShowPhoto.Visible = true;
        //                            imgPhoto.ImageUrl = strLoadFolderPath + txtIDCard.Text.Trim() + System.IO.Path.GetExtension(hpf.FileName); ;
        //                            ApplyImgs.Value = txtIDCard.Text.Trim() + System.IO.Path.GetExtension(hpf.FileName);
        //                        }
        //                    }
        //                }
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {

        //    }
        //}

        #endregion

        /// <summary>
        /// 申报次数查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void drpApplyplight_SelectedIndexChanged(object sender, EventArgs e)
        {

            if (!string.IsNullOrEmpty(txtIDCard.Text))
            {
                if (drpApplyplight.SelectedValue == "A")
                {
                    string LastDate = OtherClass.getLastApplyDate(txtIDCard.Text);
                    if (LastDate.Trim().Length > 0)
                    {
                        txtLastApplyTime.Text = common.ChangeDateFormatToString(Convert.ToDateTime(LastDate));
                    }
                }
                else
                    txtLastApplyTime.Text = "";
            }
            else 
            {
                txtLastApplyTime.Text = "";
            }
        }

        protected void drpApplyJobRank_SelectedIndexChanged(object sender, EventArgs e)
        {
            string JobRank = drpApplyJobRank.SelectedValue;
            if (JobRank != "-1")
            {
                if (JobRank == "52")
                {
                    txtSpecialityName.Enabled = true;
                    txtSpecialityEndTime.Enabled = true;
                    drpSpecialityLevel.Enabled = true;
                    txtSpecialitapproveUnit.Enabled = true;
                    drpSpecialitPersonalRank.Enabled = true;
                    txtAwardsName.Enabled = true;
                    txtAwardsDateTime.Enabled = true;
                    drpAwardsLevel.Enabled = true;
                    drpAwardsRank.Enabled = true;
                    txtAwardsPersonal.Enabled = true;
                }
                else
                {
                    string JobRankLevel = OtherClass.getJobRankLevelByJobRanK(JobRank);
                    if (JobRankLevel == "9")
                    {
                        txtSpecialityName.Enabled = true;
                        txtSpecialityEndTime.Enabled = true;
                        drpSpecialityLevel.Enabled = true;
                        txtSpecialitapproveUnit.Enabled = true;
                        drpSpecialitPersonalRank.Enabled = true;
                        txtAwardsName.Enabled = true;
                        txtAwardsDateTime.Enabled = true;
                        drpAwardsLevel.Enabled = true;
                        drpAwardsRank.Enabled = true;
                        txtAwardsPersonal.Enabled = true;

                    }
                    else
                    {
                        txtSpecialityName.Enabled = false;

                        txtSpecialityEndTime.Enabled = false;
                        drpSpecialityLevel.Enabled = false;
                        txtSpecialitapproveUnit.Enabled = false;
                        drpSpecialitPersonalRank.Enabled = false;
                        txtAwardsName.Enabled = false;
                        txtAwardsDateTime.Enabled = false;
                        drpAwardsLevel.Enabled = false;
                        drpAwardsRank.Enabled = false;
                        txtAwardsPersonal.Enabled = false;
                    }
                }
            }
        }
    }
}
